package com.xbongbong.parent.util;

import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.pojo.dto.FormDataAddDTO;
import com.xbongbong.paas.toolbox.util.StringUtil;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.enums.XbbRefTypeEnum;

import java.util.Objects;

/**
 * @author 吴峰
 * @date 2021/12/29 11:07
 */
public class SerialNoUtil {

    /**
     * 判断是否去生成流水号
     * @param groupNumber
     * @param isImport
     * @param serailNo
     * @param businessType
     * @param fieldAttrEntity
     * @return
     */
    public static boolean isToCreateSerialNo(String groupNumber, Integer isImport, String serailNo, Integer businessType, FieldAttrEntity fieldAttrEntity) {
        return Objects.nonNull(fieldAttrEntity)
                // 报价单
                && (((StringUtil.isEmpty(groupNumber) && Objects.equals(businessType, XbbRefTypeEnum.QUOTATION.getCode()) && !Objects.equals(isImport, BasicConstant.ONE ))
                // 其他特殊流水号 红冲销项发票 红冲进项发票
                || (StringUtil.isEmpty(serailNo)&& !Objects.equals(businessType, XbbRefTypeEnum.QUOTATION.getCode()) && !Objects.equals(isImport, BasicConstant.ONE ) ))
                // 导入
                || ( Objects.equals(isImport, BasicConstant.ONE ) && Objects.equals(fieldAttrEntity.getStrictController(), BasicConstant.ONE)))
                ;

    }
}
